/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.web.servlet;

import com.web.daoimpl.StudentDaoImpl;
import com.web.entity.Grade;
import com.web.service.Testdaoimpl;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author liqianru
 */
@WebServlet("/admin_getGrade")
public class Admin_getGrade extends HttpServlet {

    StudentDaoImpl service=new StudentDaoImpl();
    List<Grade> gradeList=new ArrayList<>();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       if(req.getParameter("action").equals("getall")){
        gradeList=service.getGrade();
        //
        req.setAttribute("gradeList", gradeList);
        //
        req.getRequestDispatcher("/admin_Grade.jsp").forward(req, resp);
       }
       if(req.getParameter("action").equals("search")){
           String keyword=req.getParameter("keyword");
           System.out.println(keyword);
           gradeList=service.getGbykeyword(keyword);
           //
            req.setAttribute("gradeList", gradeList);
        //
        req.getRequestDispatcher("/admin_Grade.jsp").forward(req, resp);
       }
     
       
    }
    
}
